<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="vue.js," />










<meta name="description" content="之前我们基于Vue.js CLI创建了一个模板项目，现在我们来修改成一个简单多页面网站。  模板项目结构123456789101112131415161718192021222324252627282930.|-- build                            // 项目构建(webpack)相关代码|   |-- build.js                     /">
<meta name="keywords" content="vue.js">
<meta property="og:type" content="article">
<meta property="og:title" content="Vue.js 2.0 学习 ---Vue.js Cli修改Demo">
<meta property="og:url" content="http://blog.powerone.cn/2018/03/09/A.3.Vue-project-HelloWorld2/index.html">
<meta property="og:site_name" content="PowerOne">
<meta property="og:description" content="之前我们基于Vue.js CLI创建了一个模板项目，现在我们来修改成一个简单多页面网站。  模板项目结构123456789101112131415161718192021222324252627282930.|-- build                            // 项目构建(webpack)相关代码|   |-- build.js                     /">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://blog.powerone.cn/img/vue.js/5.1.png">
<meta property="og:image" content="http://blog.powerone.cn/img/vue.js/5.2.png">
<meta property="og:updated_time" content="2018-03-09T03:32:17.602Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Vue.js 2.0 学习 ---Vue.js Cli修改Demo">
<meta name="twitter:description" content="之前我们基于Vue.js CLI创建了一个模板项目，现在我们来修改成一个简单多页面网站。  模板项目结构123456789101112131415161718192021222324252627282930.|-- build                            // 项目构建(webpack)相关代码|   |-- build.js                     /">
<meta name="twitter:image" content="http://blog.powerone.cn/img/vue.js/5.1.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://blog.powerone.cn/2018/03/09/A.3.Vue-project-HelloWorld2/"/>





  <title>Vue.js 2.0 学习 ---Vue.js Cli修改Demo | PowerOne</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">PowerOne</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">Recording of the PowerOne</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://blog.powerone.cn/2018/03/09/A.3.Vue-project-HelloWorld2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="powerone.cn">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="PowerOne">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Vue.js 2.0 学习 ---Vue.js Cli修改Demo</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-09T11:32:17+08:00">
                2018-03-09
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/vue-js/" itemprop="url" rel="index">
                    <span itemprop="name">vue.js</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <blockquote>
<p>之前我们基于Vue.js CLI创建了一个模板项目，现在我们来修改成一个简单多页面网站。</p>
</blockquote>
<h1 id="模板项目结构"><a href="#模板项目结构" class="headerlink" title="模板项目结构"></a>模板项目结构</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">.</span><br><span class="line">|-- build                            // 项目构建(webpack)相关代码</span><br><span class="line">|   |-- build.js                     // 生产环境构建代码</span><br><span class="line">|   |-- check-version.js             // 检查node、npm等版本</span><br><span class="line">|   |-- dev-client.js                // 热重载相关</span><br><span class="line">|   |-- dev-server.js                // 构建本地服务器</span><br><span class="line">|   |-- utils.js                     // 构建工具相关</span><br><span class="line">|   |-- webpack.base.conf.js         // webpack基础配置</span><br><span class="line">|   |-- webpack.dev.conf.js          // webpack开发环境配置</span><br><span class="line">|   |-- webpack.prod.conf.js         // webpack生产环境配置</span><br><span class="line">|-- config                           // 项目开发环境配置</span><br><span class="line">|   |-- dev.env.js                   // 开发环境变量</span><br><span class="line">|   |-- index.js                     // 项目一些配置变量</span><br><span class="line">|   |-- prod.env.js                  // 生产环境变量</span><br><span class="line">|   |-- test.env.js                  // 测试环境变量</span><br><span class="line">|-- src                              // 源码目录</span><br><span class="line">|   |-- components                     // vue公共组件</span><br><span class="line">|   |-- store                          // vuex的状态管理</span><br><span class="line">|   |-- App.vue                        // 页面入口文件</span><br><span class="line">|   |-- main.js                        // 程序入口文件，加载各种公共组件</span><br><span class="line">|-- static                           // 静态文件，比如一些图片，json数据等</span><br><span class="line">|   |-- data                           // 群聊分析得到的数据用于数据可视化</span><br><span class="line">|-- .babelrc                         // ES6语法编译配置</span><br><span class="line">|-- .editorconfig                    // 定义代码格式</span><br><span class="line">|-- .gitignore                       // git上传需要忽略的文件格式</span><br><span class="line">|-- README.md                        // 项目说明</span><br><span class="line">|-- favicon.ico </span><br><span class="line">|-- index.html                       // 入口页面</span><br><span class="line">|-- package.json                     // 项目基本信息</span><br><span class="line">.</span><br></pre></td></tr></table></figure>
<h2 id="package-json"><a href="#package-json" class="headerlink" title="package.json"></a>package.json</h2><p>package.json文件是项目根目录下的一个文件，定义该项目开发所需要的各种模块以及一些项目配置信息（如项目名称、版本、描述、作者等）。</p>
<h3 id="scripts字段"><a href="#scripts字段" class="headerlink" title="scripts字段"></a>scripts字段</h3><p>package.json文件里有一个scripts字段。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&quot;scripts&quot;: &#123;</span><br><span class="line">    &quot;dev&quot;: &quot;node build/dev-server.js&quot;,</span><br><span class="line">    &quot;build&quot;: &quot;node build/build.js&quot;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure></p>
<p> 在开发环境下，在命令行中运行npm run dev就相当于在执行node build/dev-server.js。所以script字段是用来指定npm相关命令的缩写的。</p>
<h3 id="dependencies字段和devDependencies字段"><a href="#dependencies字段和devDependencies字段" class="headerlink" title="dependencies字段和devDependencies字段"></a>dependencies字段和devDependencies字段</h3><p>dependencies字段指定了项目运行时所依赖的模块，devDependencies字段指定了项目开发时所依赖的模块。在命令行中运行npm install命令，会自动安装dependencies和devDependencies字段中的模块。<br>package.json还有很多配置相关项，想进一步了解package.json的可参考：<a href="https://docs.npmjs.com/files/package.json" target="_blank" rel="noopener">https://docs.npmjs.com/files/package.json</a></p>
<h2 id="webpack配置相关"><a href="#webpack配置相关" class="headerlink" title="webpack配置相关"></a>webpack配置相关</h2><p>上面说到在命令行中npm run dev就相当于在执行node build/dev-server.js，想必dev-server.js这个文件是十分重要的，它是在开发环境下构建时第一个要运行的文件。后面我们会对webpack进行详细学习。</p>
<h3 id="dev-server-js"><a href="#dev-server-js" class="headerlink" title="dev-server.js"></a>dev-server.js</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">...</span><br><span class="line">...</span><br><span class="line"><span class="comment">// http-proxy可以实现转发所有请求代理到后端真实API地址，以实现前后端开发完全分离</span></span><br><span class="line"><span class="comment">// 在config/index.js中可以对proxyTable想进行配置</span></span><br><span class="line"><span class="keyword">var</span> proxyMiddleware = <span class="built_in">require</span>(<span class="string">'http-proxy-middleware'</span>)</span><br><span class="line">...</span><br><span class="line">...</span><br><span class="line"><span class="comment">// 热加载要使用webpack-dev-middleware在没有webpack-dev-server的时候进行热加载</span></span><br><span class="line"><span class="keyword">var</span> hotMiddleware = <span class="built_in">require</span>(<span class="string">'webpack-hot-middleware'</span>)(compiler)</span><br><span class="line"><span class="comment">// 当html-webpack-plugin模板改变是强制进行页面重新加载</span></span><br><span class="line">compiler.plugin(<span class="string">'compilation'</span>, <span class="function"><span class="keyword">function</span> (<span class="params">compilation</span>) </span>&#123;</span><br><span class="line">  compilation.plugin(<span class="string">'html-webpack-plugin-after-emit'</span>, <span class="function"><span class="keyword">function</span> (<span class="params">data, cb</span>) </span>&#123;</span><br><span class="line">    hotMiddleware.publish(&#123; <span class="attr">action</span>: <span class="string">'reload'</span> &#125;)</span><br><span class="line">    cb()</span><br><span class="line">  &#125;)</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
<h3 id="webpack-base-conf-js"><a href="#webpack-base-conf-js" class="headerlink" title="webpack.base.conf.js"></a>webpack.base.conf.js</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">...</span><br><span class="line">...</span><br><span class="line"><span class="built_in">module</span>.export = &#123;</span><br><span class="line">    <span class="comment">// 编译入口文件</span></span><br><span class="line">    entry: &#123;&#125;,</span><br><span class="line">    <span class="comment">// 编译输出路径</span></span><br><span class="line">    output: &#123;&#125;,</span><br><span class="line">    <span class="comment">// 一些解决方案配置</span></span><br><span class="line">    resolve: &#123;&#125;,</span><br><span class="line">    resolveLoader: &#123;&#125;,</span><br><span class="line">    <span class="built_in">module</span>: &#123;</span><br><span class="line">        <span class="comment">// 各种不同类型文件加载器配置</span></span><br><span class="line">        loaders: &#123;</span><br><span class="line">        ...</span><br><span class="line">        ...</span><br><span class="line">        <span class="comment">// js文件用babel转码</span></span><br><span class="line">        &#123;</span><br><span class="line">            test: <span class="regexp">/\.js$/</span>,</span><br><span class="line">            loader: <span class="string">'babel'</span>,</span><br><span class="line">            include: projectRoot,</span><br><span class="line">            <span class="comment">// 哪些文件不需要转码</span></span><br><span class="line">            exclude: <span class="regexp">/node_modules/</span></span><br><span class="line">        &#125;,</span><br><span class="line">        ...</span><br><span class="line">        ...</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;,</span><br><span class="line">    <span class="comment">// vue文件一些相关配置</span></span><br><span class="line">    vue: &#123;&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="check-version-js"><a href="#check-version-js" class="headerlink" title="check-version.js"></a>check-version.js</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">// 加载语义化版本测试库</span><br><span class="line">var semver = require(&apos;semver&apos;)</span><br><span class="line">// 定制控制台日志的输入样式</span><br><span class="line">var chalk = require(&apos;chalk&apos;)</span><br><span class="line">// 引入package.json文件</span><br><span class="line">var packageConfig = require(&apos;../package.json&apos;)</span><br><span class="line">var exec = function (cmd) &#123;</span><br><span class="line">  return require(&apos;child_process&apos;)</span><br><span class="line">    .execSync(cmd).toString().trim()</span><br><span class="line">&#125;</span><br><span class="line">// 定义node和npm版本需求所组成的数组</span><br><span class="line">var versionRequirements = [</span><br><span class="line">  &#123;</span><br><span class="line">    name: &apos;node&apos;,</span><br><span class="line">    currentVersion: semver.clean(process.version),</span><br><span class="line">    versionRequirement: packageConfig.engines.node</span><br><span class="line">  &#125;,</span><br><span class="line">  &#123;</span><br><span class="line">    name: &apos;npm&apos;,</span><br><span class="line">    currentVersion: exec(&apos;npm --version&apos;),</span><br><span class="line">    versionRequirement: packageConfig.engines.npm</span><br><span class="line">  &#125;</span><br><span class="line">]</span><br><span class="line">module.exports = function () &#123;</span><br><span class="line">  var warnings = []</span><br><span class="line">  // 依次判断版本是否符合要求</span><br><span class="line">  for (var i = 0; i &lt; versionRequirements.length; i++) &#123;</span><br><span class="line">    var mod = versionRequirements[i]</span><br><span class="line">    if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) &#123;</span><br><span class="line">      warnings.push(mod.name + &apos;: &apos; +</span><br><span class="line">        chalk.red(mod.currentVersion) + &apos; should be &apos; +</span><br><span class="line">        chalk.green(mod.versionRequirement)</span><br><span class="line">      )</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">  ...</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>想把webpack完全搞懂还是需要费很大功夫的，我感觉自己也只是入了一个门而已，要想深入了解webpack还是要去官网看说明文档。<br><a href="http://webpack.github.io/docs/" target="_blank" rel="noopener">http://webpack.github.io/docs/</a><br><a href="https://webpack.js.org/configuration/" target="_blank" rel="noopener">https://webpack.js.org/configuration/</a></p>
<h2 id="babelrc"><a href="#babelrc" class="headerlink" title=".babelrc"></a>.babelrc</h2><p>Babel解释器的配置文件，存放在根目录下。Babel是一个转码器，项目里需要用它将ES6代码转为ES5代码。这里有一篇阮一峰老师写的相关文章供参考：Babel 入门教程<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">// 设定转码规则</span><br><span class="line">&quot;presets&quot;: [&quot;es2015&quot;, &quot;stage-2&quot;],</span><br><span class="line">// 转码的一些插件</span><br><span class="line">&quot;plugins&quot;: [&quot;transform-runtime&quot;],</span><br><span class="line">&quot;comments&quot;: false</span><br></pre></td></tr></table></figure></p>
<h2 id="editorconfig"><a href="#editorconfig" class="headerlink" title=".editorconfig"></a>.editorconfig</h2><p> 该文件定义项目的编码规范，编辑器的行为会与.editorconfig 文件中定义的一致，并且其优先级比编辑器自身的设置要高，这在多人合作开发项目时十分有用而且必要。</p>
 <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"> root = true</span><br><span class="line"></span><br><span class="line">[*]    // 对所有文件应用下面的规则</span><br><span class="line">charset = utf-8                    // 编码规则用utf-8</span><br><span class="line">indent_style = space               // 缩进用空格</span><br><span class="line">indent_size = 2                    // 缩进数量为2个空格</span><br><span class="line">end_of_line = lf                   // 换行符格式</span><br><span class="line">insert_final_newline = true        // 是否在文件的最后插入一个空行</span><br><span class="line">trim_trailing_whitespace = true    // 是否删除行尾的空格</span><br></pre></td></tr></table></figure>
<p>了解更多请参考官方配置文档<a href="http://editorconfig.org/" target="_blank" rel="noopener">http://editorconfig.org/</a></p>
<h1 id="模块关系"><a href="#模块关系" class="headerlink" title="模块关系"></a>模块关系</h1><p>我们通过对源代码分析，可以知道demo模块之间的大体关系。<br>目录：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">|-- src                              // 源码目录</span><br></pre></td></tr></table></figure></p>
<p><img src="/img/vue.js/5.1.png" alt="PowerOne"><br>1 main.js：应用入口文件<br>2 App.js：初始化组件</p>
<h1 id="修改需求"><a href="#修改需求" class="headerlink" title="修改需求"></a>修改需求</h1><p>  我们要实现如下效果的一个网站<br><img src="/img/vue.js/5.2.png" alt="PowerOne"><br>  有四个模块：首页、公司介绍、关于我们、易点咨询。</p>
<h2 id="配置入口文件main-js"><a href="#配置入口文件main-js" class="headerlink" title="配置入口文件main.js"></a>配置入口文件main.js</h2><p> 这个文件不需要修改<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// The Vue build version to load with the `import` command</span></span><br><span class="line"><span class="comment">// (runtime-only or standalone) has been set in webpack.base.conf with an alias.</span></span><br><span class="line"><span class="keyword">import</span> Vue <span class="keyword">from</span> <span class="string">'vue'</span></span><br><span class="line"><span class="keyword">import</span> App <span class="keyword">from</span> <span class="string">'./App'</span></span><br><span class="line"><span class="keyword">import</span> router <span class="keyword">from</span> <span class="string">'./router'</span></span><br><span class="line"></span><br><span class="line">Vue.config.productionTip = <span class="literal">false</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/* eslint-disable no-new */</span></span><br><span class="line"><span class="keyword">new</span> Vue(&#123;</span><br><span class="line">  el: <span class="string">'#app'</span>,</span><br><span class="line">  router,</span><br><span class="line">  template: <span class="string">'&lt;App/&gt;'</span>,</span><br><span class="line">  components: &#123; App &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure></p>
<h2 id="初始化组件App-vue开发"><a href="#初始化组件App-vue开发" class="headerlink" title="初始化组件App.vue开发"></a>初始化组件App.vue开发</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">  &lt;div id=<span class="string">"app"</span>&gt;</span><br><span class="line">    &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">"nav-top"</span>&gt;</span><br><span class="line">          &lt;!-- 引入公用的头部 header组件 --&gt;</span><br><span class="line">            &lt;v-header&gt;&lt;/v-header&gt;</span><br><span class="line">    &lt;/div&gt;</span><br><span class="line">    </span><br><span class="line">    &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">"banner"</span>&gt;</span><br><span class="line">    &lt;<span class="regexp">/div&gt;</span></span><br><span class="line"><span class="regexp">    </span></span><br><span class="line"><span class="regexp">    &lt;div class="contianer"&gt;</span></span><br><span class="line"><span class="regexp">        &lt;!-- 路由中的几个组件在这里被渲染，默认被渲染的为第一个组件，也就是home组件  --&gt;</span></span><br><span class="line"><span class="regexp">        &lt;router-view&gt;&lt;/</span>router-view&gt;</span><br><span class="line">    &lt;<span class="regexp">/div&gt;</span></span><br><span class="line"><span class="regexp">  &lt;/</span>div&gt;</span><br><span class="line">&lt;<span class="regexp">/template&gt;</span></span><br><span class="line"><span class="regexp"></span></span><br><span class="line"><span class="regexp">&lt;script&gt;</span></span><br><span class="line"><span class="regexp">import header from './</span>components/header.vue<span class="string">'</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">export default &#123;</span></span><br><span class="line"><span class="string">  name: '</span>app<span class="string">',</span></span><br><span class="line"><span class="string">  components: &#123;</span></span><br><span class="line"><span class="string">    '</span>v-header<span class="string">': header</span></span><br><span class="line"><span class="string">  &#125;</span></span><br><span class="line"><span class="string">&#125;</span></span><br><span class="line"><span class="string">&lt;/script&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&lt;style&gt;</span></span><br><span class="line"><span class="string">#app &#123;</span></span><br><span class="line"><span class="string">  font-family: '</span>Avenir<span class="string">', Helvetica, Arial, sans-serif;</span></span><br><span class="line"><span class="string">  -webkit-font-smoothing: antialiased;</span></span><br><span class="line"><span class="string">  -moz-osx-font-smoothing: grayscale;</span></span><br><span class="line"><span class="string">  text-align: center;</span></span><br><span class="line"><span class="string">  color: #2c3e50;</span></span><br><span class="line"><span class="string">&#125;</span></span><br><span class="line"><span class="string">.nav-top &#123;</span></span><br><span class="line"><span class="string">  position: absolute;</span></span><br><span class="line"><span class="string">  top: 100;</span></span><br><span class="line"><span class="string">  left: 50%;</span></span><br><span class="line"><span class="string">  margin-left: -520px;</span></span><br><span class="line"><span class="string">  z-index: 99;</span></span><br><span class="line"><span class="string">&#125;</span></span><br><span class="line"><span class="string">.banner&#123;</span></span><br><span class="line"><span class="string">  width: 100%;</span></span><br><span class="line"><span class="string">  height: 370px;</span></span><br><span class="line"><span class="string">  overflow: hidden;</span></span><br><span class="line"><span class="string">  background: url("assets/banner.jpg");</span></span><br><span class="line"><span class="string">  background-repeat: no-repeat;</span></span><br><span class="line"><span class="string">&#125;</span></span><br><span class="line"><span class="string">&lt;/style&gt;</span></span><br></pre></td></tr></table></figure>
<h2 id="创建公用头部组件"><a href="#创建公用头部组件" class="headerlink" title="创建公用头部组件"></a>创建公用头部组件</h2><p>在components 文件下创建header.vue<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">  &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">"header"</span>&gt;</span><br><span class="line">    &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">"header-wrapper"</span>&gt;</span><br><span class="line">      &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">"logo"</span>&gt;</span><br><span class="line">        &lt;router-link to=<span class="string">"/home"</span>&gt;&lt;img src="../assets/logo.png" alt width="210"&gt;&lt;/router-link&gt;</span><br><span class="line">      &lt;/div&gt;</span><br><span class="line">      &lt;ul <span class="class"><span class="keyword">class</span></span>=<span class="string">"nav"</span>&gt;</span><br><span class="line">        &lt;li&gt;&lt;router-link to="/home"&gt;首页&lt;/router-link&gt;&lt;/li&gt;</span><br><span class="line">        &lt;li&gt;&lt;router-link to="/introduce"&gt;公司介绍&lt;/router-link&gt;&lt;/li&gt;</span><br><span class="line">        &lt;li&gt;&lt;router-link to="/employment"&gt;关于我们&lt;/router-link&gt;&lt;/li&gt;</span><br><span class="line">        &lt;li&gt;&lt;router-link to="/consult"&gt;易点咨询&lt;/router-link&gt;&lt;/li&gt;</span><br><span class="line">      &lt;<span class="regexp">/ul&gt; </span></span><br><span class="line"><span class="regexp">    &lt;/</span>div&gt; </span><br><span class="line">  &lt;<span class="regexp">/div&gt;</span></span><br><span class="line"><span class="regexp">&lt;/</span>template&gt;</span><br><span class="line"></span><br><span class="line">&lt;style&gt;</span><br><span class="line">.header&#123;</span><br><span class="line">  width:<span class="number">1200</span>px;</span><br><span class="line">  height:<span class="number">100</span>px;</span><br><span class="line">  margin:<span class="number">0</span> auto;</span><br><span class="line">  color:#fff;</span><br><span class="line">&#125;</span><br><span class="line">.header-wrapper&#123;</span><br><span class="line">  width:<span class="number">1200</span>px;</span><br><span class="line">  height:<span class="number">100</span>px;</span><br><span class="line">&#125;</span><br><span class="line">.logo&#123;</span><br><span class="line">  width:<span class="number">210</span>px;</span><br><span class="line">  height:<span class="number">100</span>px;</span><br><span class="line">  float:left;</span><br><span class="line">&#125;</span><br><span class="line">.nav&#123;</span><br><span class="line">  width:<span class="number">700</span>px;</span><br><span class="line">  height:<span class="number">100</span>px;</span><br><span class="line">  font-size:<span class="number">15</span>px;</span><br><span class="line">  float:right;</span><br><span class="line">&#125;</span><br><span class="line">.nav li&#123;</span><br><span class="line">  float:left;</span><br><span class="line">  margin-right:<span class="number">30</span>px;</span><br><span class="line">  height:<span class="number">34</span>px;</span><br><span class="line">  line-height:<span class="number">34</span>px;</span><br><span class="line">  overflow:hidden;</span><br><span class="line">  margin-top:<span class="number">34</span>px;</span><br><span class="line">&#125;</span><br><span class="line">.nav li:last-child&#123;</span><br><span class="line">  margin-right:<span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line">.nav a&#123;</span><br><span class="line">  display:inline-block;</span><br><span class="line">  padding:<span class="number">0</span> <span class="number">13</span>px;</span><br><span class="line">  color:#fff;</span><br><span class="line">  border-radius:<span class="number">15</span>px;</span><br><span class="line">&#125;</span><br><span class="line">.nav a.router-link-active&#123;</span><br><span class="line">  background:#c10514;</span><br><span class="line">&#125;</span><br><span class="line">&lt;<span class="regexp">/style&gt;</span></span><br></pre></td></tr></table></figure></p>
<h2 id="修改router组件"><a href="#修改router组件" class="headerlink" title="修改router组件"></a>修改router组件</h2><p>修改router/index.js, 加入新的组件。<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> Vue <span class="keyword">from</span> <span class="string">'vue'</span></span><br><span class="line"><span class="keyword">import</span> Router <span class="keyword">from</span> <span class="string">'vue-router'</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 引入项目的四个模块组件</span></span><br><span class="line"><span class="keyword">import</span> introduce <span class="keyword">from</span> <span class="string">'@/components/introduce'</span></span><br><span class="line"><span class="keyword">import</span> home <span class="keyword">from</span> <span class="string">'@/components/home'</span></span><br><span class="line"><span class="keyword">import</span> employment <span class="keyword">from</span> <span class="string">'@/components/employment'</span></span><br><span class="line"><span class="keyword">import</span> consult <span class="keyword">from</span> <span class="string">'@/components/consult'</span></span><br><span class="line"></span><br><span class="line">Vue.use(Router)</span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> <span class="keyword">new</span> Router(&#123;</span><br><span class="line">  routes: [</span><br><span class="line">    &#123;</span><br><span class="line">      path: <span class="string">'/'</span>,</span><br><span class="line">      name: <span class="string">'home'</span>,</span><br><span class="line">      component: home</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">      path: <span class="string">'/home'</span>,</span><br><span class="line">      name: <span class="string">'home'</span>,</span><br><span class="line">      component: home</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">      path: <span class="string">'/introduce'</span>,</span><br><span class="line">      name: <span class="string">'introduce'</span>,</span><br><span class="line">      component: introduce</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">      path: <span class="string">'/employment'</span>,</span><br><span class="line">      name: <span class="string">'employment'</span>,</span><br><span class="line">      component: employment</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">      path: <span class="string">'/consult'</span>,</span><br><span class="line">      name: <span class="string">'consult'</span>,</span><br><span class="line">      component: consult</span><br><span class="line">    &#125;</span><br><span class="line">  ]</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure></p>
<h2 id="创建其他组件"><a href="#创建其他组件" class="headerlink" title="创建其他组件"></a>创建其他组件</h2><p>根据router里需要的组件，创建：</p>
<ol>
<li>/components/home.vue</li>
<li>/components/introduce.vue</li>
<li>components/employment.vue</li>
<li>/components/consult.vue</li>
</ol>
<h3 id="home-vue"><a href="#home-vue" class="headerlink" title="home.vue"></a>home.vue</h3><p>为了简单起见，我们把demo里的Hello.vue rename成home.vue</p>
<h3 id="其他-vue"><a href="#其他-vue" class="headerlink" title="其他.vue"></a>其他.vue</h3><p>起他三个，我们分别建一个文件。<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">    &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">"intro"</span>&gt;</span><br><span class="line">        咨询介绍</span><br><span class="line">    &lt;<span class="regexp">/div&gt;</span></span><br><span class="line"><span class="regexp">&lt;/</span>template&gt;</span><br><span class="line">&lt;style&gt;</span><br><span class="line">.intro&#123;</span><br><span class="line">    font-size:<span class="number">20</span>px;</span><br><span class="line">    color:#000;</span><br><span class="line">    margin:<span class="number">20</span>px auto;</span><br><span class="line">&#125;</span><br><span class="line">&lt;<span class="regexp">/style&gt;</span></span><br></pre></td></tr></table></figure></p>
<h2 id="浏览网站"><a href="#浏览网站" class="headerlink" title="浏览网站"></a>浏览网站</h2><p>这时demo网站被修改成自己需要的样子。至少简单的框架搭建好了。<br>需要需要修改后的demo代码，请访问：<br><a href="http://git.oschina.net/frankliugang/Vue.js-Cli-Study/tree/master/demo01" target="_blank" rel="noopener">http://git.oschina.net/frankliugang/Vue.js-Cli-Study/tree/master/demo01</a></p>
<h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1><ol>
<li>了解Vue.js cli 模板项目的建构。</li>
<li>知道各个文件和folder的用途</li>
<li>通过模板修改并添加组件，实现简单的网站功能。</li>
</ol>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/vue-js/" rel="tag"># vue.js</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/03/09/B.1 Hexo intruduction for Powerone blog/" rel="next" title="如何多人编辑Hexo blog">
                <i class="fa fa-chevron-left"></i> 如何多人编辑Hexo blog
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/06/13/Z.9.2 Other-picture-sample/" rel="prev" title="图片展示">
                图片展示 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">powerone.cn</p>
              <p class="site-description motion-element" itemprop="description">Wechat, SpringBatch, JavaScript, Vue.js</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">8</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">4</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">4</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#模板项目结构"><span class="nav-number">1.</span> <span class="nav-text">模板项目结构</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#package-json"><span class="nav-number">1.1.</span> <span class="nav-text">package.json</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#scripts字段"><span class="nav-number">1.1.1.</span> <span class="nav-text">scripts字段</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#dependencies字段和devDependencies字段"><span class="nav-number">1.1.2.</span> <span class="nav-text">dependencies字段和devDependencies字段</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#webpack配置相关"><span class="nav-number">1.2.</span> <span class="nav-text">webpack配置相关</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#dev-server-js"><span class="nav-number">1.2.1.</span> <span class="nav-text">dev-server.js</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#webpack-base-conf-js"><span class="nav-number">1.2.2.</span> <span class="nav-text">webpack.base.conf.js</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#check-version-js"><span class="nav-number">1.2.3.</span> <span class="nav-text">check-version.js</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#babelrc"><span class="nav-number">1.3.</span> <span class="nav-text">.babelrc</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#editorconfig"><span class="nav-number">1.4.</span> <span class="nav-text">.editorconfig</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#模块关系"><span class="nav-number">2.</span> <span class="nav-text">模块关系</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#修改需求"><span class="nav-number">3.</span> <span class="nav-text">修改需求</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#配置入口文件main-js"><span class="nav-number">3.1.</span> <span class="nav-text">配置入口文件main.js</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#初始化组件App-vue开发"><span class="nav-number">3.2.</span> <span class="nav-text">初始化组件App.vue开发</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建公用头部组件"><span class="nav-number">3.3.</span> <span class="nav-text">创建公用头部组件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#修改router组件"><span class="nav-number">3.4.</span> <span class="nav-text">修改router组件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建其他组件"><span class="nav-number">3.5.</span> <span class="nav-text">创建其他组件</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#home-vue"><span class="nav-number">3.5.1.</span> <span class="nav-text">home.vue</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#其他-vue"><span class="nav-number">3.5.2.</span> <span class="nav-text">其他.vue</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#浏览网站"><span class="nav-number">3.6.</span> <span class="nav-text">浏览网站</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#总结"><span class="nav-number">4.</span> <span class="nav-text">总结</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">powerone.cn</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
